package com.dream.springmvc.filter;


import com.dream.springmvc.filter.operators.*;
import com.dream.springmvc.value.*;
import com.dream.springmvc.value.Value;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author zhaoshichang
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class NumberFilter extends FilterBase<NumberValue> {
    private DoubleOperator op;

    @Override
    protected boolean supports(Value<?> value) {
        return value instanceof NumberValue;
    }

    @Override
    protected boolean doMeet(NumberValue other) {
        return op.getOpf().eval(getVal().getValue(), other.getValue());
    }
}
